import http from '@/utils/request'

// 积分记录类型
export enum PointsAction {
  Task, // 任务活动
  Exchange, // 积分兑换
}

export interface IIntegralInfo {
  name: string
  point: number
  id?: string
  parentId?: string
}

export interface IPointsTransaction {
  type: PointsAction
  childId: string
  id: string
}

export async function pointsList(): Promise<IIntegralInfo[]> {
  return http('points/list')
}

export async function points(data: IIntegralInfo): Promise<void> {
  return http('points/add', data)
}

export async function removePoint(data: Pick<IIntegralInfo, 'id'>): Promise<void> {
  return http('points/remove', data)
}

export async function pointsTransaction(data: IPointsTransaction): Promise<void> {
  return http('points/transaction', data)
}
